﻿app.controller('IndexCtrl',
    ['$scope', '$http', '$filter', '$state', 'wemaskPlus', 'httpPlus', 'utils',
    function ($scope, $http, $filter, $state, wemaskPlus, httpPlus, utils) {
        utils.setTitle('会员中心');
        $scope.showMask = false;
        $scope.currCard = undefined;
        $scope.couponCount = undefined;
        $scope.cards = [];
        $scope.chooseCard_click = function () {
            $scope.showMask = true;
        };
        $scope.btncancelMask_click = function () {
            $scope.showMask = false;
        };
        $scope.chooseCurrCard_click = function (data) {
            $scope.currCard = data;
            $scope.showMask = false;
        };
        httpPlus
            .RRRApi('MemberCenterPage/InitMemberCenterIndexPage')
            .then(function (data) {
                $scope.couponCount = data.CouponCount;
                $scope.cards = _.map(data.CardList, function (_card) {
                    return {
                        cardName: _card.CardName,
                        cardNo: _card.CardNo,
                        cardId: _card.CardID,
                        cardPoints: _card.CardPoints,
                        cardValue: _card.CardValue + _card.CardGiftValue,
                        cardLogo: _card.CardLogo
                    }
                });
                $scope.currCard = $scope.cards[0];
            }, function (error) {
                alert(error);
            });
    }]);